<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="lib/vue.js"></script>
</head>

<body>
    <div id="app">
        <com :parentmsg="msg" @func="getmsg"></com>
    </div>

    <template id="tmpl">
        <div>
            <h1>这是子元素---{{parentmsg}}</h1>
            <input type="button" value="向父组件传递消息" @click="sendMsg">
        </div>
    </template>
    <script>
        var com = {
            template: '#tmpl',
            data() {
                return {
                    msg: 'hhhhh'
                }
            },
            props: ['parentmsg'],
            methods: {
                sendMsg() {
                    this.$emit('func', this.msg)
                }
            },
        }

        var vm = new Vue({
            el: '#app',
            data: {
                msg: '........',
                msgFormSon: ''
            },
            methods: {
                getmsg(data) {
                    this.msgFormSon = data;
                    console.log(this.msgFormSon)
                }
            },
            components: {
                com
            }
        });
    </script>
</body>

</html>